package com.firstcare.android_dylibrary.bean;

import com.alibaba.fastjson.JSONObject;
import com.firstcare.android_dylibrary.DYApplication;
import com.firstcare.android_dylibrary.bean.base.BaseModelProxy;
import com.firstcare.android_dylibrary.network.URLSet;
import com.firstcare.android_dylibrary.network.request.DYRequest;
import com.firstcare.android_dylibrary.network.request.ModelListRequest;
import com.rdxer.xxlibrary.HTTPUtils.listener.ErrorListener;
import com.rdxer.xxlibrary.HTTPUtils.listener.FailedListener;
import com.rdxer.xxlibrary.HTTPUtils.listener.OKListener;
import com.rdxer.xxlibrary.utils.Log;

import java.util.List;

/**
 * Created by chenyichao on 2016/6/26.
 */
public class ReportDetailsProxy extends BaseModelProxy<ReportDetails> {
    public  void getProjectData( final OKListener<List<ReportDetailsProxy>> okListener, FailedListener failedListener, ErrorListener errorListener){
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("id","222");
        ModelListRequest<ReportDetailsProxy> request = new ModelListRequest<ReportDetailsProxy>(URLSet.getProjectData, jsonObject, new OKListener<List<ReportDetailsProxy>>() {
            @Override
            public void onOK(List<ReportDetailsProxy> res, JSONObject response) {
                /// 登陆成功需要处理的事情
                Log.e(response);
                okListener.onOK(res,response);
            }
        }, failedListener, errorListener) {
            @Override
            protected Object getTargetData(JSONObject response) throws Exception {
                return response.getJSONObject("data").getJSONArray("list");
            }
        };
        DYApplication.getShared().getApi().addToRequestQueue(request);
    }
    public void getProjectExecl(final OKListener<Object> okListener,FailedListener failedListener,ErrorListener errorListener){
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("id","222");
        DYRequest<Object> request = new DYRequest<Object>(URLSet.getProjectExcel, jsonObject, okListener,failedListener,errorListener){
            @Override
            protected Object getTargetData(JSONObject response) throws Exception {
                return response.getJSONObject("data").getString("string");
            }
        };
        DYApplication.getShared().getApi().addToRequestQueue(request);
    }
}
